%{
    This file is part of StemCellQC, a video bioinformatics software
    toolkit for analysis of phase contrast microscopy videos.
    Copyright 2013-2015 

    StemCellQC is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    StemCellQC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StemCellQC.  If not, see <http://www.gnu.org/licenses/>.
%}

function plotWithShadeColor(y, plot_color)
% function plotWithShade(y) made by brett bays 11/2013
% based on Aaron Seitz's "prettyplot" function
% y is a matrix of data, where each column contains the data for a single timepoint or measurement
% plotWithShade will plot the mean of each timepoint and shade +/- 1 standard error of the mean at each point

% the function is written to only take a single argument, y, but could easily be amended to take arguments controlling the color, lineWidth, axes labels, etc.

if plot_color == 'g'
    color = 'green';
elseif plot_color == 'b'
    color = 'blue';
elseif plot_color == 'r'
    color = 'red';
elseif plot_color == 'y'
    color = 'yellow';
elseif plot_color == 'c'
    color = 'cyan';
elseif plot_color == 'm'
    color = 'magenta';
elseif plot_color == 'k'
    color = 'black';
end

x = [1:size(y,2)]';
theMeans = [mean(y)]';
theSEMs = [std(y)./sqrt(size(y,1))]';

theErr1 = theMeans+theSEMs;
theErr2 = theMeans-theSEMs;

% figure;
plot1 = plot(x,theMeans,plot_color,'LineWidth',2);
h1 = patch([x;x(end:-1:1)], [theErr1;theErr2(end:-1:1)], plot_color, 'FaceAlpha', .25, 'FaceColor', color, 'EdgeColor', color, 'EdgeAlpha', .25);
end
